let systemStyle = {
  state: {
    appui_theme: "",
    body_theme_primary: "",
    platform_language: "", // 当前平台的语言
    appui_themes: {
      blue:"theme-blue",
      dark: "theme-dark",
      darkblue: "theme-darkblue",
      grey: "theme-grey",
      light: "theme-light",
      lightbrown: "theme-lightbrown",
    },
    body_themes_primary: {
      Purple: "body-theme-primary-purple",
      Cerulean: "body-theme-primary-cerulean",
      Blue: "body-theme-primary-blue",
      Gold: "body-theme-primary-gold",
      Blue2: "body-theme-primary-blue2",
      Green: "body-theme-primary-green",
      Orange: "body-theme-primary-orange",
      Pink: "body-theme-primary-pink",
      Red: "body-theme-primary-red",
      Silver: "body-theme-primary-silver",
    },
    settingInfo: {
      accountInfo: [
        {
          id: 1,
          name: "基本设置",
          i18nName: "setup.basicSet",
          icon: "basic-setting",
        },
      ],
      preference: [
        {
          id: 2,
          name: "外观",
          i18nName: "setup.appearance",
          icon: "appearance",
        },
        // {
        //   id: 3,
        //   name: "通用",
        //   i18nName: "setup.common",
        //   icon: "system-setting",
        // },
        // {
        //   id: 4,
        //   name: "快捷键",
        //   i18nName: "setup.shortcut",
        //   icon: "keyboard-shortcut",
        // },
        // {
        //   id: 5,
        //   name: "关于智能训练与验证子系统",
        //   i18nName: "setup.about",
        //   icon: "about-jtyun-cloud",
        // },
      ],
    },
    themeBgColorList: [
      {
        id: "blue",
      },
      {
        id: "dark",
      },
      {
        id: "darkblue",
      },
      {
        id: "grey",
      },
      {
        id: "light",
      },
      {
        id: "lightbrown",
      },
    ],
    themeSelectedColorList: [
      {
        id: "Purple",
        color: "#9373EE",
      },
      {
        id: "Cerulean",
        color: "#5F80E9",
      },
      {
        id: "Blue",
        color: "#587DF1",
      },
      {
        id: "Gold",
        color: "#9A7D56",
      },
      {
        id: "Blue2",
        color: "#00C3EE",
      },
      {
        id: "Green",
        color: "#039E74",
      },
      {
        id: "Orange",
        color: "#FA8C16",
      },
      {
        id: "Pink",
        color: "#E86CA4",
      },
      {
        id: "Red",
        color: "#FD6874",
      },
      {
        id: "Silver",
        color: "#8E8374",
      },
    ],
    shortcutsList: [
      {
        title: true,
        name: "接口管理",
        nameEn: "interfacesManage",
        show: true,
        flag: 1,
        shortcut_way: "",
      },
      {
        title: false,
        name: "保存",
        nameEn: "save",
        show: true,
        flag: 1,
        shortcut_way: "Ctrl + S",
      },
      {
        title: false,
        name: "复制",
        nameEn: "copy",
        show: true,
        flag: 1,
        shortcut_way: "Ctrl + D",
      },
      {
        title: false,
        name: "删除",
        nameEn: "delete",
        show: true,
        flag: 1,
        shortcut_way: "Del",
        disabled: true,
      },
      {
        title: true,
        name: "数据模型",
        nameEn: "dataModel",
        show: true,
        flag: 2,
        shortcut_way: "",
        disabled: true,
      },
      {
        title: false,
        name: "切换到上方输入框",
        nameEn: "changeToInputBoxTop",
        show: true,
        flag: 2,
        shortcut_way: "⬆",
        disabled: true,
      },
      {
        title: false,
        name: "切换到下方输入框",
        nameEn: "changeToInputBoxBottom",
        show: true,
        flag: 2,
        shortcut_way: "⬇",
        disabled: true,
      },
      {
        title: false,
        name: "切换到右侧输入框",
        nameEn: "changeToInputBoxRight",
        show: true,
        flag: 2,
        shortcut_way: "Shift + Tab",
        disabled: true,
      },
      {
        title: false,
        name: "切换到左侧输入框",
        nameEn: "changeToInputBoxLeft",
        show: true,
        flag: 2,
        shortcut_way: "Tab",
        disabled: true,
      },
      {
        title: true,
        name: "代码编辑器",
        nameEn: "codeEditor",
        show: true,
        flag: 3,
        shortcut_way: "",
      },
      {
        title: false,
        name: "查找",
        nameEn: "find",
        show: true,
        flag: 3,
        shortcut_way: "Ctrl + F",
        disabled: true,
      },
      {
        title: false,
        name: "替换",
        nameEn: "replace",
        show: true,
        flag: 3,
        shortcut_way: "Ctrl + H",
        disabled: true,
      },
      {
        title: true,
        name: "通用",
        nameEn: "general",
        show: true,
        flag: 4,
        shortcut_way: "",
      },
      {
        title: false,
        name: "设置",
        nameEn: "setup",
        show: true,
        flag: 4,
        shortcut_way: "Ctrl + ,",
      },
      {
        title: false,
        name: "换行",
        nameEn: "newLine",
        show: true,
        flag: 4,
        shortcut_way: ["Enter", "Shift + Enter"],
        disabled: true,
      },
      {
        title: false,
        name: "隐藏窗口",
        nameEn: "hideWindow",
        show: true,
        flag: 4,
        shortcut_way: "Shift + Alt + W",
        disabled: true,
      },
      {
        title: false,
        name: "界面放大",
        nameEn: "zoomInPage",
        show: true,
        flag: 4,
        shortcut_way: "Ctrl + Shift + =",
        disabled: true,
      },
      {
        title: false,
        name: "界面缩小",
        nameEn: "shrinkPage",
        show: true,
        flag: 4,
        shortcut_way: "Ctrl + -",
        disabled: true,
      },
      {
        title: false,
        name: "查看所有快捷键",
        nameEn: "showAllShortcutKeys",
        show: true,
        flag: 4,
        shortcut_way: "Ctrl + /",
      },
    ],
    languageOptions: [
      {
        label: "简体中文",
        value: "zh",
        explain: "简体中文",
        explainEn: "Simplified Chinese",
      },
      {
        label: "English",
        value: "en",
        explain: "英文",
        explainEn: "English",
      },
    ],
    i18nData: {
      en: {
        isCategoryValid:
          "Category code is illegal and should be a six digit number!",
      },
      zh: {
        isCategoryValid: "类别代号不正确，应为6位数字！",
      },
    },
  },
  mutations: {
    SET_SYSTEM_STYLE(state, res) {
      state.appui_theme = state.appui_themes[res.themeBgColor];
      state.body_theme_primary = state.body_themes_primary[res.themeColor];
      Array.from(document.body.classList).forEach((item) => {
        if (item.includes("body-theme-primary-") || item.includes("theme-")) {
          document.body.classList.remove(item);
        }
      });
      document.body.classList.add(state.appui_theme);
      document.body.classList.add(state.body_theme_primary);
      const themeColorMap = {
        blue: {
          Purple: "rgba(72, 71, 104, 1)",
          Cerulean: "rgba(68, 77, 104, 1)",
          Blue: "rgba(58, 73, 117, 1)",
          Gold: "rgba(88, 83, 75, 1)",
          Blue2: "rgba(30, 83, 104, 1)",
          Green: "rgba(31, 84, 77, 1)",
          Orange: "rgba(112, 87, 61, 1)",
          Pink: "rgba(104, 68, 93, 1)",
          Red: "rgba(111, 67, 77, 1)",
          Silver: "rgba(92, 92, 93, 1)",
        },
        dark: {
          Purple: "rgba(68, 65, 96, 1)",
          Cerulean: "rgba(64, 71, 96, 1)",
          Blue: "rgba(55, 67, 108, 1)",
          Gold: "rgba(84, 76, 66, 1)",
          Blue2: "rgba(27, 77, 95, 1)",
          Green: "rgba(27, 78, 68, 1)",
          Orange: "rgba(108, 81, 52, 1)",
          Pink: "rgba(101, 62, 84, 1)",
          Red: "rgba(107, 60, 68, 1)",
          Silver: "rgba(89, 86, 84, 1)",
        },
        darkblue: {
          Purple: "rgba(72, 71, 104, 1)",
          Cerulean: "rgba(68, 77, 104, 1)",
          Blue: "rgba(58, 73, 117, 1)",
          Gold: "rgba(88, 83, 75, 1)",
          Blue2: "rgba(30, 83, 104, 1)",
          Green: "rgba(31, 84, 77, 1)",
          Orange: "rgba(112, 87, 61, 1)",
          Pink: "rgba(104, 68, 93, 1)",
          Red: "rgba(111, 67, 77, 1)",
          Silver: "rgba(92, 92, 93, 1)",
        },
        grey: {
          Purple: "rgba(80, 76, 102, 1)",
          Cerulean: "rgba(76, 82, 102, 1)",
          Blue: "rgba(66, 78, 115, 1)",
          Gold: "rgba(96, 87, 73, 1)",
          Blue2: "rgba(38, 88, 102, 1)",
          Green: "rgba(39, 89, 75, 1)",
          Orange: "rgba(120, 92, 59, 1)",
          Pink: "rgba(112, 73, 91, 1)",
          Red: "rgba(119, 71, 75, 1)",
          Silver: "rgba(100, 97, 91, 1)",
        },
        light: {
          Purple: "rgba(212, 203, 243, 1)",
          Cerulean: "rgba(196, 208, 242, 1)",
          Blue: "rgba(193, 207, 244, 1)",
          Gold: "rgba(215, 207, 195, 1)",
          Blue2: "rgba(165, 229, 243, 1)",
          Green: "rgba(166, 217, 204, 1)",
          Orange: "rgba(245, 211, 174, 1)",
          Pink: "rgba(239, 201, 220, 1)",
          Red: "rgba(246, 200, 204, 1)",
          Silver: "rgba(211, 209, 204, 1)",
        },
        lightbrown: {
          Purple: "rgba(211, 197, 224, 1)",
          Cerulean: "rgba(194, 201, 223, 1)",
          Blue: "rgba(192, 200, 225, 1)",
          Gold: "rgba(213, 200, 176, 1)",
          Blue2: "rgba(164, 223, 224, 1)",
          Green: "rgba(165, 211, 185, 1)",
          Orange: "rgba(244, 205, 155, 1)",
          Pink: "rgba(238, 195, 201, 1)",
          Red: "rgba(245, 194, 185, 1)",
          Silver: "rgba(209, 202, 185, 1)",
        },
      };

      // 3. 获取背景色
      const __jsonSchemaEditor__bg =
        themeColorMap[res.themeBgColor]?.[res.themeColor] || "";

      // 4. 应用样式
      document.querySelectorAll(".quote-header").forEach((item) => {
        item.style.setProperty(
          "--jsonSchemaEditor--bg",
          __jsonSchemaEditor__bg
        );
      });
    },
  },
  actions: {
    setSystemDefaultStye({ commit }) {
      if (!localStorage.getItem('themeConfig')) {
        localStorage.setItem('themeConfig', 'blueBlue');
      }
      const themeConfig = localStorage.getItem("themeConfig");
      const themeBgColor = themeConfig.slice(0, themeConfig.search(/[A-Z]/));
      const themeColor = themeConfig.slice(themeConfig.search(/[A-Z]/));
      commit("SET_SYSTEM_STYLE", { themeBgColor, themeColor });
    },
  },
};
export default systemStyle;
